<?php
namespace app\common\util;
/**
 * Created by PhpStorm.
 * User: lelouchms
 * Date: 2019/3/24
 * Time: 21:04
 */
class SignUtil
{

    public function getSign($encodeData, $appSecret)
    {
        ksort($encodeData);
        $query = http_build_query($encodeData) . "&secret=" . $appSecret;
        return md5($query);
    }

    public function verifySign($sign, $encodeData, $appSecret)
    {
        unset($encodeData['sign']);
        $signData = $this->getSign($encodeData, $appSecret);
        if ($sign !== $signData) return false;
        return true;
    }


}